var ilivehelp_array=document.getElementsByTagName("iframe");
var ilivehelp_counti=0;
for (ilivehelp_i=0;ilivehelp_i<ilivehelp_array.length;ilivehelp_i++)
{
if (ilivehelp_array[ilivehelp_i].src.indexOf("http://www.itecheasy.com.cn/auto")!=-1)
{
ilivehelp_counti++;//大于1表示存在
}

}

var toppx;		
var toborder;  
var jid;
var tabname;
var istyle;
var kinfo;
var knickname;
var t = 0;var l = 0;
if (document.all)
{
	t = screen.width;l = screen.height;   
}
else 
{
	t = window.outerWidth;l = window.outerHeight;
}
t = (t-500)/2;l = (l-200)/2; 
var search = getTagParam(); 
var paraString = search.split(",");	
var GET = new Array();		
for (var i = 0; i < paraString.length; i ++)		
{					
	GET[i] = unescape(paraString[i]);			
}
jid = GET[0];
tabname = GET[1];
istyle = GET[2];
kinfo = GET[3];
knickname = GET[4];
var c_mail = jid.split("@");
var itab = jid.indexOf("@")+1;
toppx = GET[5]
toborder = GET[6]
jid = translateEtJid(jid);
var jid1 = jid;
jid = c_mail[0]+"1."+c_mail[1]+"b"+itab+"@www.itecheasy.com.cn";
var serverurl = "http://www.itecheasy.com.cn";
var imgstyleurl="http://www.itecheasy.com.cn";
var loginhref = imgstyleurl+"/SingleTag/anony/cn/anony.html?jid="+jid+"&kinfo="+escape(kinfo)+"&knickname="+escape(knickname);
var randomNum=parseInt(1000*Math.random());
var imgsrc = "";
if(istyle != "" || istyle.length >1)
{
	var imgsrc2 = serverurl+":9090/plugins/presence/status?jid="+jid+"&images="+imgstyleurl+"/style/"+istyle+"/images/--IMAGE--.gif&rand="+randomNum;
	imgsrc = "<img border='0' SRC='"+imgsrc2+"' style='cursor:pointer' alt='click to talk' onClick='{disauto();var win=window.open(\""+loginhref+"\",\"v\",\"width=620,height=447,top="+t+",left="+l+",status=no,toolbar=no\");win.focus();}'>";
}
var iwindowWidth, iwindowHeight; 
if (self.innerHeight)
{  // all except Explorer 
	iwindowWidth = self.innerWidth; 
	iwindowHeight = self.innerHeight; 
}
else if (document.documentElement && document.documentElement.clientHeight)
{ // Explorer 6 Strict Mode 
	iwindowWidth = document.documentElement.clientWidth; 
	iwindowHeight = document.documentElement.clientHeight; 
}
else if (document.body)
{ // other Explorers 
	iwindowWidth = document.body.clientWidth; 
	iwindowHeight = document.body.clientHeight; 
} 
if(iwindowWidth == undefined)
{
	iwindowWidth = 300;
}
else
{
	iwindowWidth = iwindowWidth/2-180;
}
if(iwindowHeight == undefined)
{
	iwindowHeight = 250;
}
else
{
	iwindowHeight = iwindowHeight/2-65;
}
var ilastScrollY=0;
//functions ---------
function translateEtJid( str )
{
	var apos = str.indexOf("@");
	var tmp = str.replace("@", ".");
	return tmp.concat("b" + apos);
}
function getTagParam() 
{ 
	var col = document.getElementsByTagName("script"); 
	var jsrc=col.item(col.length-1).src; 
	var i=jsrc.indexOf("?"); 
	var words=jsrc.substr(i+1,jsrc.length); 
	return words; 
}
function ilivehFloatR()
{
	var diffY;
	if (document.documentElement && document.documentElement.scrollTop)
	{
		diffY = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		diffY = document.body.scrollTop
	}
	else
	{/*Netscape stuff*/}
	percent=.1*(diffY-ilastScrollY); 
	if(percent>0)
	{
		percent=Math.ceil(percent); 
	}
	else
	{
		percent=Math.floor(percent);
	}
	document.getElementById("iLiveHelpR").style.top=parseInt(document.getElementById("iLiveHelpR").style.top)+percent+"px";
	document.getElementById("iLiveHelp2R").style.top=parseInt(document.getElementById("iLiveHelp2R").style.top)+percent+"px";
	ilastScrollY=ilastScrollY+percent; 
}
var page = document.location;
page = page+"";
if(page.indexOf("52917") != -1)
{
document.write ("<div id='iLiveHelpR' style='left:"+toborder+"px;POSITION:absolute;TOP:"+toppx+"px;cursor:pointer;z-index:9999;'><span onClick='{disauto();var win=window.open(\""+loginhref+"\",\"v\",\""+
"width=620,height=447,top="+t+",left="+l+",status=no,toolbar=no\");win.focus();}'><font color='#0350DC'></font></span></div>");
opener = null;
window.close();
}
else
{
document.write ("<div id='iLiveHelpR' style='left:"+toborder+"px;POSITION:absolute;TOP:"+toppx+"px;cursor:pointer;z-index:9999;'>"+imgsrc+"<span onClick='{disauto();var win=window.open(\""+loginhref+"\",\"v\",\""+
"width=620,height=447,top="+t+",left="+l+",status=no,toolbar=no\");win.focus();}'><font color='#0350DC'>"+tabname+"</font></span></div>");
}
var suspendcode12="<div id=\"iLiveHelp2R\" style='width:393px;height:130px;left:"+iwindowWidth+"px;position:absolute;top:"+iwindowHeight+"px;z-index:9999;display:none'>";
suspendcode12= suspendcode12+"<img src='"+imgstyleurl+"/SingleTag/anony/cn/images/auto.gif' width=\"393px\" height=\"130px\" border=\"0px\" usemap=\"#invitwin\"/>";
suspendcode12= suspendcode12+"<map name=\"invitwin\" style='cursor:pointer' id=\"invitwin\">";
suspendcode12= suspendcode12+"<area shape=\"rect\" coords=\"257,98,308,122\" style='cursor:pointer' onclick='{applyInvit();var win=window.open(\""+loginhref+"\",\"v\",\"width=620,height=447,top="+t+",left="+l+",toolbar=no\");win.focus();}'/>";
suspendcode12= suspendcode12+"<area shape=\"rect\" coords=\"320,99,371,122\" style='cursor:pointer' onclick='rejectInvit();'/>";
suspendcode12= suspendcode12+"</map></div>";
document.write(suspendcode12);

window.setInterval("ilivehFloatR()",1);
//var page = document.location;
if (page.length > 300)
{
	page = page.substring(0, 299);
}
page = escape(page);
if (ilivehelp_counti==0)
{	
document.write("<div id=\"setauto\"style='display:none'><iframe MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src="+imgstyleurl+"/auto/getauto.html?jid="+jid1+"&url="+page+"&rand="+randomNum+"></iframe></div>");
}
function applyInvit()
{
	document.getElementById("iLiveHelp2R").style.display='none';
}
function rejectInvit()
{
	document.getElementById("iLiveHelp2R").style.display='none';
}
function disauto()
{
	if(dtime2 != null)
	{
		clearInterval(dtime2);
	}
}
//------------------------------------------------
var oldHash = null;
var dtime2 = null;
var inviteCId = null;

function getiHash() 
{
	var hash = window.location.hash;
	if ((hash.length >= 1) && (hash.charAt(0) == '#')) 
	{
		hash = hash.substring(1);
	} 
	return hash;
}
function setiDivHtml()
{
	document.getElementById("iLiveHelp2R").style.display='';
}
function autoGetiHash()
{
	var newHash = getiHash(); 
	if (newHash != oldHash && oldHash != null)
	{
		inviteCId = getCustomerId(newHash);
		if(inviteCId != "" && !isNaN(inviteCId))
		{
			setiDivHtml();
			clearInterval(dtime2);
		}
	}
	oldHash = newHash;
} 
function getCustomerId(beforPharse)
{
	if(beforPharse.lastIndexOf("a") == -1)
	{
		return "";
	}
	else
	{
		beforPharse = beforPharse.substring(beforPharse.lastIndexOf("a")+1);
		return beforPharse;
	}
}
dtime2 = window.setInterval("autoGetiHash();",1000);
